package com.matt.domain.teaching;

import com.matt.commons.exception.BusinessException;
import com.matt.commons.model.Domain;

import com.matt.foundation.model.ErrorCode;
import com.matt.foundation.utils.ModelUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;

/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2018/1/18
 * 园区自建课程
 * *******************************
 */
@Entity
@Table(name = "course_area_public")
@Data
@EqualsAndHashCode(callSuper = true)
public class CourseAreaPublic extends Domain{

    @Column(name = "name", columnDefinition = "varchar(50) COMMENT '名称'")
    private String name;

    @Column(columnDefinition = "int default 0  COMMENT '课时'")
    private Integer durationTime = 0;

    @Column(columnDefinition = "varchar(32) COMMENT '适用对象id'")
    private String targetObjectId;

    @Column(columnDefinition = "int default 0  COMMENT '起始月龄'")
    private Integer beginMonth = 0;

    @Column(columnDefinition = "int default 0   COMMENT '截止月龄'")
    private Integer endMonth = 0;

    @Column(columnDefinition = "varchar(50) COMMENT '核心能力目标' ")
    private String coreCompetence;

    @Column(columnDefinition = "varchar(255) COMMENT '综合技能目标' ")
    private String integratedSkill;

    @Column(columnDefinition = "varchar(500) COMMENT '教学目标'")
    private String teachGoal;

    @Column(columnDefinition = "varchar(500) COMMENT '教学难点'")
    private String teachDifficulty;

    @Column(columnDefinition = "varchar(500) COMMENT '教学重点'")
    private String teachKeyPoint;

    @Column(columnDefinition = "varchar(500) COMMENT '个人准备'")
    private String prepareContent;

    @Column(columnDefinition = "varchar(500) COMMENT '用具准备'")
    private String prepareTool;

    @Column(columnDefinition = "varchar(500) COMMENT '特别注意事项'")
    private String specialRemarks;

    @Column(columnDefinition = "longtext comment '环节'")
    private String linkItems;

    @Column(columnDefinition = "longtext comment '观测点'")
    private String observerPoints;

    @Column(columnDefinition = "longtext comment '附件'")
    private String attachments;

    @Column(name = "areaId", columnDefinition = "varchar(32) COMMENT '园区Id'")
    private String areaId;

    @Column(name = "typeName", columnDefinition = "varchar(255) COMMENT '课程类型名'")
    private String typeName;

    @Column(name = "typeCode", columnDefinition = "int default 1 COMMENT '课程类型码'")
    private Integer typeCode;

    @Column(name = "createdId", columnDefinition = "varchar(32) COMMENT '创建人Id'")
    private String createdId;

    @Column(name = "lastModified", columnDefinition = " datetime DEFAULT NOW() COMMENT '最后修改时间' ")
    private Date lastModified = new Date();

    @Column(name = "lastModifiedId", columnDefinition = "varchar(32) COMMENT '最后修改Id'")
    private String lastModifiedId;

    @Column(columnDefinition = "int default 0 COMMENT '0：待审核，1：已审核， 2：已审核， 3：已禁用'")
    private Integer status = 0;

    @Column(name = "courseAreaId", columnDefinition = "varchar(32) COMMENT '自建课程id'")
    private String courseAreaId;


    public CourseAreaPublic merge(CourseArea courseArea){
        try {
            ModelUtil.copyNotNullPropertiesExcludeId(this, courseArea);
        }catch (Exception e){
            throw new BusinessException(ErrorCode.ENTITY_MERGE_ERROR, "拷贝属性出错");
        }
        return this;
    }
}
